export const CONF = {
  password: /^(((?=.*\d)(?=.*[a-zA-Z])(?=.*[~!@#$%^&*\)\(\`\-\+\=\_\|\{\}\[\]\:\;\,\.\/?]))|((?=.*\d)(?=.*[a-z])(?=.*[A-Z]))|((?=.*[a-z])(?=.*[A-Z])(?=.*[~!@#$%^&*\)\(\`\-\+\=\_\|\{\}\[\]\:\;\,\.\/?])))[\da-zA-Z~!@#$%^&*\)\(\`\-\+\=\_\|\{\}\[\]\:\;\,\.\?\/?]{1,2000}$/,
  command: /^[a-z_A-Z0-9-\.!@#\$%\\\^&\*\)\(\+=\{\}\[\]\/",'<>~\·`\?:;|\s]+$/
}

export const isPC = function () {
  const userAgentInfo = navigator.userAgent;
  const Agents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"];
  let flag = true;
  for (let v = 0; v < Agents.length; v++) {
      if (userAgentInfo.indexOf(Agents[v]) > 0) {
          flag = false;
          break;
      }
  }
  return flag
}

export const statusObj = {
  running: 'running',
  ok: 'running',
  binded: 'running',
  error: 'error',
  building: 'deleting',
  deleting: 'deleting',
  restarting: 'deleting',
  starting_up: 'deleting',
  shutting_down: 'deleting',
  updating: 'deleting',
  creating: 'deleting',
  shutdown: 'stop',
  disabled: 'stop',
  stop: 'stop'
}

// 标签、注解转为key：value
export const labelToKeyValue = (label) => {
  const result = {}
  label.length>0 && label.forEach((item) => {
    result[item.key] = item.value
  })
  return result
}
